<?php

namespace App\Http\BackendControllers;

use App\Models\Post;

class PostController extends Controller
{

    /*
     * 文章列表
     */
    public function index()
    {
        $posts = Post::withoutGlobalScope('available')->paginate(6);

        return view('backend.post.index', compact('posts'));
    }


    public function status($post_id)
    {
        $status = request('status');
        if (!in_array($status, [-1, 0, 1])) {
            return err('', '状态错误');
        }
        Post::withoutGlobalScope('available')->where('id', $post_id)->update([
            'status' => $status
        ]);
        return res('', '更改成功');

    }


}
